package com.eascs.ticket.project.service;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eascs.ticket.common.service.BaseSevice;
import com.eascs.ticket.project.dao.ProjectDao;
import com.eascs.ticket.project.entity.Project;
import com.eascs.ticket.project.entity.ProjectUpdate;

@Service
public class ProjectService extends BaseSevice {
	@Inject
	private ProjectDao projectDao;

	public Project getProjectById(String id) {
		return this.proxyDao.getById(Project.class, id);
	}

	@Transactional(transactionManager = "ticketTransactionManager")
	public Project insertProject(Project project) {
		this.proxyDao.insert(project);

		/*
		 * DictionarySeq dictionarySeq = new DictionarySeq();
		 * EntityUtil.initInsertEntity(dictionarySeq);
		 * dictionarySeq.setCode("project-" + project.getCode());
		 * dictionarySeq.setPrefix(project.getCode() + "-");
		 * dictionarySeq.setCurrent(0);
		 */
		return project;
	}

	public void updateProject(ProjectUpdate projectUpdate) {
		this.proxyDao.updateById(projectUpdate);
	}

	public List<Object[]> getValidProjects() {
		return projectDao.getValidProjects();
	}

	public List<Object[]> getValidProjectViewList() {
		return this.projectDao.getValidProjectViewList();
	}

	public List<Object[]> getAllProjectViewList() {
		return this.projectDao.getAllProjectViewList();
	}
}
